package com.example.jsonformateapplication.dao;
import com.example.jsonformateapplication.entity.User;
import java.util.HashMap;
import java.util.Map;

/**
 * @author 胡新毅 乐武护
 * @since 2024/9/14
 * *对数据库的操作
 */
public class UserDao {
    private static Map<Integer, User>map=new HashMap<Integer,User>();
    static {
        map.put(1,new User(1,"消炎",18,"xy@qq.com","123456","159951"));
        map.put(2,new User(2,"李幸运",18,"lxy@qq.com", "123456","159951"));
        map.put(3,new User(3,"陈平安",18, "cpa@qq.com", "123456","159951"));
        map.put(4,new User(4,"张小凡",18,"zxf@qq.com", "123456","159951"));
    }
    public  static  Map<Integer,User> getAll(){
        return  map;
    }
    public static  User getByid(int id){
        return map.get(id);
    }
    public static void add(User user){
        map.put(user.getId(), user);
    }
    public  static void update(User user){
        map.put(user.getId(), user);
    }

    public static void delete(int id){
        map.remove(id);
    }
}
